import {getFocus,getFans,getFllowUser,unFllowUser} from "../Api/account";
const state ={
	
	focuslist:[],
	fanslist:[],
};
const mutations ={
	SET_FOCUS_LIST(state,list){
		state.focuslist=list
	},
	SET_FANS_LIST(state,list){
		state.fanslist=list
	},
	SET_FOCUS_TRUE(state,index){
		state.fanslist[index].isFollow=true
	},
	SET_FOCUS_FALSES(state,index){
		console.log(state.fanslist[index])
		state.fanslist[index].isFollow=false
	},
};
const actions ={
	
	async unFllowUser(context,index){
		console.log(index)
		let id=context.state.fanslist[index].userId
		let result = await unFllowUser(id)
		console.log(result)
		if(result.data.status==200)
		{
			console.log('quxiaoguanzhu')
			context.commit('SET_FOCUS_FALSES',index)
		}
	},
	
	async getFllowUser(context,index){
		let id=context.state.fanslist[index].userId
		let result = await getFllowUser(id)
		console.log(result)
		if(result.data.status==200)
		{
			console.log('guanzhu')
			context.commit('SET_FOCUS_TRUE',index)
		}
		
	},
	async getFocus(context) {
		let result = await getFocus()
		console.log(result)
		if (result.data.status == 200) {
			context.commit('SET_FOCUS_LIST',result.data.data)
		} else{
			context.commit('SET_FOCUS_LIST',[])
		}
		},
	async getFans(context) {
			let result = await getFans()
			console.log(result)
			if (result.data.status == 200) {
				context.commit('SET_FANS_LIST',result.data.data)
			}else{
			context.commit('SET_FANS_LIST',[])
		}
	 }
};

const getters ={
	Focus(){
		return state.focuslist || []
	},
	Fans(){
		return state.fanslist || []
	},
};
export default{
	state,
	mutations,
	actions,
	getters,
}